<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://www.goodfox.com/jsp/tags/power" prefix="p"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%> 
<script type="text/javascript">
/**
 * 页面初始化加载的js方法
 */
$(function(){
	loadOrgTree("orgTree");
});
function loadOrgTree(orgTreeId){
	var showPower="${p:isPower('/organization/goOrganizationDetail.shtml',sessionScope.loginAccount)}";
	$.ajax({
    	"dataType": "json",
    	"type": "POST",
    	"url": "<c:url value="/organization/organizationTreeQuery.shtml"/>",
    	"data": "",
    	async: false,
    	"success": function(data){
    		for(var i=0;i<data.orgList.length;i++){
    			var org =data.orgList[i];
    			var href="javascript;";
    			if(showPower){
        			href="<c:url value="/organization/goOrganizationDetail.shtml"/>?orgId="+org.orgId;
    			}
    			if(org.orgId==data.curOrgId){
    				var topUl="<li><a href='"+href+"' target='ajax' rel='orgShowPage'>"+org.orgName+"</a><ul id='"+orgTreeId+"_"+org.orgId+"'></ul></li>";
    				if(org.subCount==0){
    					topUl="<li><a href='"+href+"' target='ajax' rel='orgShowPage'>"+org.orgName+"</a></li>";
    				}
    				$("#"+orgTreeId).append(topUl);
    			}else{
    				var ul="<li><a href='"+href+"' target='ajax' rel='orgShowPage'>"+org.orgName+"</a><ul id='"+orgTreeId+"_"+org.orgId+"'></ul></li>";
    				if(org.subCount==0){
    					ul="<li><a href='"+href+"' target='ajax' rel='orgShowPage'>"+org.orgName+"</a></li>";
    				}
    				$("#"+orgTreeId+"_"+org.orgIdParent).append(ul);
    			}
    		}
    	}
    }); 
}
</script>
<div class="pageContent">
	<div class="tabs">
		<div class="tabsHeader">
			<div class="tabsHeaderContent">
				<ul>
					<li><a href="javascript:;"><span>组织机构树</span></a></li>
				</ul>
			</div>
		</div>
		<div class="tabsContent">
			<div>
				<div layoutH="160" class="contLeft">
					<ul id="orgTree" class="tree expand">
					
					</ul>    
				</div> 
				<div id="orgShowPage" class="unitBox contRight">
				
				</div>
			</div>
		</div>
	</div>
</div>
